package com.yanqu.road.server.cmd.activity.specialcookboy;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.specialcookboy.SpecialCookBoyProto;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.Command;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.YanQuMessageUtils;
import io.netty.channel.ChannelHandlerContext;

@Cmd(code = CrossProtocol.C_SPECIAL_COOK_BOY_USE_CODE_RESP_GAME_TO_CROSS,desc = "小当家使用分享码的结果从区服转发上跨服,跨服转发到原始区服")
public class CrossSpecialCookBoyUseCodeResultRespCmd implements Command{

    @Override
    public void execute(ChannelHandlerContext ctx, YanQuMessage yanQuMessage) throws Exception {
        SpecialCookBoyProto.SpecialCookBoyUseCodeRespGameToCross respGameToCross = SpecialCookBoyProto.SpecialCookBoyUseCodeRespGameToCross.parseFrom(yanQuMessage.getBytes());
        SpecialCookBoyProto.SpecialCookBoyUseShareCodeResultFromCross.Builder builder = SpecialCookBoyProto.SpecialCookBoyUseShareCodeResultFromCross.newBuilder();
        builder.setCode(respGameToCross.getCode());
        builder.setRet(respGameToCross.getRet());
        //发回原始请求上来的区服
        YanQuMessage message = YanQuMessageUtils.buildMessage(GameProtocol.S_SPECIAL_COOK_BOY_USE_SHARE_CODE_RESULT_FROM_CROSS, builder);
        MessageHelper.sendPacket(respGameToCross.getFromServerId(), respGameToCross.getFromUserId(), message);

    }
}
